<!DOCTYPE html>
<html lang="en">
<head>
	<title>Class.js :: Unit Tests :: ProtoLove</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<script type="text/javascript" src="../lib/qunit/qunit.js"></script>
	<script type="text/javascript" src="../src/Class.js"></script>
	<link type="text/css" rel="stylesheet" href="css/screen.css" media="screen" />
</head>
<body>

<div id="unit-output">
	<h1 id="qunit-header">ProtoLove Unit Tests - Class.js</h1>
	<h2 id="qunit-banner"></h2>
	<div id="qunit-testrunner-toolbar"></div>
	<h2 id="qunit-userAgent"></h2>
	<ol id="qunit-tests"><li></li></ol>
</div>

<script type="text/javascript">
	with (QUnit) {

		test('Class.create()', function() {
			var Die = Class.create();
			Die.prototype.name = 'Die';
			typeOf(Die, 'function', 'created class is a function');
			instanceOf(new Die, Class.Base, 'instance of pulp.cls.Base');

			var SixSidedDie = Class.create(Die);
			SixSidedDie.prototype.name = 'SixSidedDie';
			var FourSidedDie = Die.createSubclass();
			FourSidedDie.prototype.name = 'FourSidedDie';
			
			equal(Die.subclasses, [SixSidedDie, FourSidedDie], 'class subclasses property populated');
			equal(Die.subclasses[0], FourSidedDie);
			equal(Die.subclasses[1], SixSidedDie);
			
			instanceOf(new SixSidedDie, Die, 'inheritance from parent');
			instanceOf(new SixSidedDie, Class.Base, 'inheritance from grandparent');

			equal(SixSidedDie.parent, Die, 'parent property');
			equal(FourSidedDie.parent, Die, 'parent property again');
			equal(Class.Base.parent, undefined, 'base class has no parent');

			equal(Die, Die.prototype.constructor, 'constructor instance property set');
		});

		test('callParent()', function() {
			var Grid = Class.create({
				initialize: function(w, h) {
					this.width = w;
					this.height = h;
				}
			});

			var Grid3D = Grid.createSubclass({
				initialize: function(w, h, d) {
					this.callParent('initialize', w, h);
					this.depth = d;
				}
			});

			var myCube = new Grid3D(5, 4, 3);
			equal(5, myCube.width);
		});

		test('extend()', function() {
			var Transition = Class.create();
			Transition.extend({
				duration: 500
			});
			equal(500, Transition.duration, 'extend class with static method')
		});

	}
</script>

</body>
</html>